// pages/personal/personal.js
const app = getApp()
Page({

    data: {
        defaultUrl: "https://img.zhxcxmall.com/ll/defalut-head-pic.png",
        isCodePop: false,
        order_entry: [
            { label: '待付款', icon: 'youhuijuan-xianxing', status: 0 },
            { label: '待配送', icon: 'peizaizhuangche-xianxing', status: 20 },
            { label: '已发货', icon: "yunshuzhongwuliu-xianxing", status: 21 },
            { label: '待自提', icon: "zitigui-xianxing", status: 11 },
            { label: '已完成', icon: "qianshoushenpitongguo-xianxing", status: 40 },
        ],
        write_off: [
            { label: '待付款', icon: 'daifukuan', status:0 },
            { label: '已支付', icon: 'tianmaobao', status: 12 },
            { label: '已完成', icon: "guanfangzhishou", status: 100 },
        ],

    },

    onLoad: function(options) {
        if (options) {
            app.share(options.mid)
        }
    },
    selectedCodePop: function() {
        this.setData({
            isCodePop: !this.data.isCodePop
        })
    },

    onShow: function() {
        let user = wx.getStorageSync("user")
        user && this.setData({
            user
        })
        this.loadData()
        app.isGetPhone().then(res => {
            if (!res) {
                wx.showModal({
                    title: '温馨提示',
                    content: '您还没有绑定手机号,请立即绑定',
                    showCancel: false,
                    confirmColor: '#ff5400',
                    success: res => {
                        if (res.confirm) {
                            wx.navigateTo({
                                url: '/pages/personal/bind-mobile',
                            })
                        }
                    }
                })
            }
        })
    },
    loadData(){
        Promise.all([
            app.http.post('user/my'),
            app.http.post('hx-order/count'),
            app.http.post('user/status'),
        ]).then(res=>{
			this.setData(Object.assign({
				count: res[0].data.count,
				hx_count: res[1].data,
			},res[2].data))
        })
    }
})